package com.jjyu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jjyu.dao.UserMapper;
import com.jjyu.entity.User;
import com.jjyu.service.UserService;
import com.jjyu.utils.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByUserName(String userName) {
        User user = userMapper.findByUserName(userName);
        return user;
    }

    @Override
    public User register(String name, String email, String password) {
        String passwordMD5 = Md5Utils.stringToMD5(password);

        int number = userMapper.addUser(name, email, passwordMD5);
        User user = userMapper.findByUserName(name);
        return user;
    }
}
